package com.wontube.smr.bo.sites;

import java.util.List;

import com.wontube.client.extension.utils.ArrayUtils;
import com.wontube.client.extension.utils.StringUtils;
import com.wontube.smr.bo.constants.StandarAnimeGenres;
import com.wontube.smr.bo.constants.StandarMovieGenres;
import com.wontube.smr.bo.constants.StandarMusicGenres;
import com.wontube.smr.bo.constants.StandarTVGenres;
import com.wontube.smr.bo.sites.imdb.ImdbMovieGenres;
import com.wontube.smr.bo.sites.youtube.YoutubeMovieGenres;
import com.wontube.smr.bo.sites.youtube.YoutubeMusicGenres;
import com.wontube.smr.client.model.po.Genre;

/**
 * @author tanggf(2012-8-15)
 *
 */
public final class GenreSelectBO {
	private GenreSelectBO(){		
	}
	
	/**
	 * 返回已修正的Movie Genres
	 * @param genres
	 * @return
	 */
	public static List<Genre> selectRemandedMovieGenres(){
		return StandarMovieGenres.listDisplayGenres();
	}
		
	/**
	 * 修正tv genre
	 * @return
	 */
	public static List<Genre> selectRemendedTVGenres(){
		return StandarTVGenres.listDisplayGenres();
	}
	
	/**
	 * 返回已修正的Music Genres
	 * @return
	 */
	public static List<Genre> selectRemendedMusicGenres(){
		return StandarMusicGenres.listDisplayGenres();
	}
	
	/**
	 * 处理Movie的一对多genres
	 * @param genreName
	 * @return
	 */
	public static String joinMovieGenres(String genreName){		
		if(StringUtils.isNullOrEmpty(genreName)){
			return null;
		}
		
		if(genreName.equals(StandarMovieGenres.HORROR)){
			return ArrayUtils.join(StandarMovieGenres.getHorrorGenres(), ",");
		}else	if(genreName.equals(StandarMovieGenres.LIFE)){
			return ArrayUtils.join(StandarMovieGenres.getLifeGenres(), ",");
		}else	if(genreName.equals(StandarMovieGenres.ANIMATION)){
				return ArrayUtils.join(StandarMovieGenres.getAnimationGenres(), ",");				
		}else	if(genreName.equals(StandarMovieGenres.OTHERS)){
			return ArrayUtils.join(StandarMovieGenres.getAllOtherGenres(), ",");
		}	
		
		return genreName;
	}
	
	/**
	 * 处理TV的一对多genres
	 * @param genre
	 * @return
	 */
	public static String joinTVGenres(String genreName){			
		if(StringUtils.isNullOrEmpty(genreName)){
			return null;
		}
		
		if(genreName.equals(StandarTVGenres.ANIMATION)){
			return ArrayUtils.join(StandarTVGenres.getAnimationGenres(), ",");
		}else if(genreName.equals(StandarTVGenres.OTHERS)){
			return ArrayUtils.join(StandarTVGenres.getAllOtherGenres(), ",");
		}
		
		return genreName;
	}
	
	/**
	 * 处理Music的一对多genres问题
	 * @param genreName
	 * @return
	 */
	public static String joinMusicGenres(String genreName){
		if(StringUtils.isNullOrEmpty(genreName)){
			return null;
		}
		
		if(genreName.equals(StandarMusicGenres.OTHERS)){
			return ArrayUtils.join(StandarMusicGenres.getAllOtherGenres(), ",");
		}
		return genreName;
	}	
	
	//====i18n genre====
	public static List<Genre> selectRemendedAnimeGenres(){
		return StandarAnimeGenres.listDisplayGenres();
	}
	
	public static List<Genre> selectI18nMovieGenres(){
		return YoutubeMovieGenres.getI18nGenres();
	}	
	public static List<Genre> selectI18nTrailerGenres(){
		return ImdbMovieGenres.getI18nGenres();
	}	
	
	public static String joinYoutubeI18nMovieGenres(String genreName){
		if(StringUtils.isNullOrEmpty(genreName)){
			return null;
		}
		if(genreName.equals(StandarMovieGenres.OTHERS)){
			return ArrayUtils.join(YoutubeMovieGenres.getI18nOtherGenres(), ",");
		}
		
		return genreName;
	}	
	public static String joinImdbI18nMovieGenres(String genreName){
		if(StringUtils.isNullOrEmpty(genreName)){
			return null;
		}
		if(genreName.equals(StandarMovieGenres.OTHERS)){
			return ArrayUtils.join(ImdbMovieGenres.getI18nOtherGenres(), ",");
		}		
		return genreName;
	}
	
	//=====i18n music genres======
	public static List<Genre> selectI18nMusicGenres(){
		return YoutubeMusicGenres.getI18nGenres();
	}	
	public static String joinYoutubeI18nMusicGenres(String genreName){
		if(StringUtils.isNullOrEmpty(genreName)){
			return null;
		}
		if(genreName.equals(StandarMusicGenres.OTHERS)){
			return ArrayUtils.join(YoutubeMusicGenres.getI18nOtherGenres(), ",");
		}		
		return genreName;
	}
	
}
